def make_simulation(order_name, file_name="", speed_num=0):
    return {
        'maintype': 'simulation',
        'order_name': order_name,
        'file_name': file_name,
        'speed_num': speed_num,
    }

# ==================== 移动到点 ====================
def move_to_point(maintype, self_id, point_x, point_y, speed):
    cmd = {
        'maintype': maintype,
        'self_id': self_id,  # int
        'point_x': point_x+483e4,  # 指定点位置x float
        'point_y': point_y+755e4,  # 指定点位置y float
        #'point_y': point_x+483e4,  # 指定点位置x float
        #'point_x': point_y+755e4,  # 指定点位置y float
        'speed': speed,  # 目标速度 int
    }
    return cmd

def MoveToPointTank(uid, x, y, speed):
    return move_to_point('movetopointtank', uid, x, y, speed)

def MoveToPointWrc(uid, x, y, speed):
    return move_to_point('movetopointwrc', uid, x, y, speed)

def MoveToPointIcv(uid, x, y, speed):
    return move_to_point('movetopointicv', uid, x, y, speed)

# ==================== 路线移动 ====================
def move_by_points(maintype, self_id, posList, speed):
    posList = [[x+483e4, y+755e4]for x,y in posList]
    #posList = [[y+755e4, x+483e4]for x,y in posList]
    return {
        'maintype': maintype,
        'self_id': self_id,  # int
        'pos_int': len(posList),  # 路线关键点数量
        'posList': posList,  # 关键点位置列表
        'speed': speed,  # 速度
    }

def MoveAsLineTank(uid, pois, speed):
    return move_by_points('moveaslinetank', uid, pois, speed)

def MoveAsLineWrc(uid, pois, speed):
    return move_by_points('moveaslinewrc', uid, pois, speed)

def MoveAsLineIcv(uid, pois, speed):
    return move_by_points('moveaslineicv', uid, pois, speed)

# ==================== 上车下车 ====================
def GetOffIcv(self_id):
    return {
        'maintype': 'getofficv',
        'self_id': self_id,
    }

def GetInIcv(self_id):
    return {
        'maintype': 'getinicv',
        'self_id': self_id,
    }

# ==================== 目标开火 ====================
def FireTargetTank(self_id, target_id, shell_type):
    return {
        'maintype': 'firetargettank',
        'self_id': self_id,
        'target_id': target_id,
        'shell_type': shell_type,
    }

def FireTargetWrc(self_id, target_id):
    return {
        'maintype': 'firetargetwrc',
        'self_id': self_id,
        'target_id': target_id,
    }

def FireTargetIcv(self_id, target_id, shell_type):
    return {
        'maintype': 'firetargeticv',
        'self_id': self_id,
        'target_id': target_id,
        'shell_type': shell_type,
    }

# ==================== 进出战壕 ====================
def DefenseIcv(self_id, zh_id):
    return {
        'maintype': 'defenseicv',
        'self_id': self_id,
        'zh_id': zh_id,
    }

def DefenseTank(self_id, zh_id):
    return {
        'maintype': 'defensetank',
        'self_id': self_id,
        'zh_id': zh_id,
    }

def UnDefenseIcv(self_id, pos_x, pos_y, course):
    return {
        'maintype': 'undefenseicv',
        'self_id': self_id,
        'pos_x': pos_x+483e4,
        'pos_y': pos_y+755e4,
        'course': course,
    }

def UnDefenseTank(self_id, pos_x, pos_y, course):
    return {
        'maintype': 'undefensetank',
        'self_id': self_id,
        'pos_x': pos_x+483e4,
        'pos_y': pos_y+755e4,
        'course': course,
    }


# ==================== 方向移动（无人机）===========
def MoveDirecWrj(uid, course):
    return {
        'maintype': 'movedirecwrj',#maintype,
        'self_id': uid,
        'course': course
    }

def HoverSelf(uid, atti):
    return {
        'maintype': 'hoverself',#maintype,
        'self_id': uid,
        'atti': atti
    }

    
# ==================== 单兵移动 ====================

def MoveToPointSold(uid, x, y, speed):
    return move_to_point('movetopointsold', uid, x, y, speed)
